/**
 * 
 */
package cz.cvut.fit.crhonjar.mi.run.hawera.tree.statement;

import cz.cvut.fit.crhonjar.mi.run.hawera.tree.TreeVisitor;

/**
 * internal representation foreach
 * 
 * @author Jarec
 * 
 */
public class ForeachTree extends StatementTree {

	private AssignmentTree assignment;
	private StatementTree block;

	/**
	 * @param assignment
	 * @param block
	 */
	public ForeachTree(AssignmentTree assignment, StatementTree block) {
		super();
		this.log.debug("> ForeachTree");
		if (assignment == null) {
			final String message = "Cannot construct foreach tree using null assignment!";
			this.log.error(message);
			throw new NullPointerException(message);
		}
		if (block == null) {
			final String message = "Cannot construct foreach tree using null block!";
			this.log.error(message);
			throw new NullPointerException(message);
		}
		this.assignment = assignment;
		this.block = block;

		this.log.debug("< ForeachTree");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cz.cvut.fit.crhonjar.mi.run.hawera.tree.TreeVisitorAcceptor#accept(cz
	 * .cvut.fit.crhonjar.mi.run.hawera.tree.TreeVisitor)
	 */
	@Override
	public void accept(TreeVisitor visitor) {
		visitor.visitForeach(this);

	}

	/**
	 * @return the assignment
	 */
	public AssignmentTree getAssignment() {
		this.log.debug(">< getAssignment");
		return this.assignment;
	}

	/**
	 * @return the block
	 */
	public StatementTree getBlock() {
		this.log.debug(">< getBlock");
		return this.block;
	}

}
